﻿@model RoadFlow.Model.HomeSet
<link href="~/RoadFlowResources/scripts/bigcolorpicker/css/jquery.bigcolorpicker.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="~/RoadFlowResources/scripts/bigcolorpicker/js/jquery.bigcolorpicker.js"></script>
<script type="text/javascript" src="~/RoadFlowResources/scripts/bigcolorpicker/js/syntaxHighlighter/shCore.js"></script>
<script type="text/javascript" src="~/RoadFlowResources/scripts/bigcolorpicker/js/syntaxHighlighter/shBrushJScript.js"></script>
<script type="text/javascript" src="~/RoadFlowResources/scripts/bigcolorpicker/js/syntaxHighlighter/shBrushJava.js"></script>
<link href="~/RoadFlowResources/scripts/bigcolorpicker/css/syntaxHighlighter/shCore.css" rel="stylesheet" type="text/css" />
<link href="~/RoadFlowResources/scripts/bigcolorpicker/css/syntaxHighlighter/shCoreDefault.css" rel="stylesheet" type="text/css" />
<link href="~/RoadFlowResources/scripts/bigcolorpicker/css/syntaxHighlighter/shThemeDefault.css" rel="stylesheet" type="text/css" />

<form id="form1" method="post">
    <br />
    @Html.AntiForgeryToken()
    <table cellpadding="0" cellspacing="1" border="0" width="90%" class="formtable" style="margin-top:10px;">
        <tr>
            <th style="width: 80px;">模块名称：</th>
            <td>
                <input type="hidden" name="Id" value="@Model.Id" />
                <input type="text" class="mytext" validate="empty" id="Name" name="Name" value="@Model.Name" style="width:300px;" />
            </td>
        </tr>
        <tr>
            <th style="width: 80px;">显示标题：</th>
            <td><input type="text" class="mytext" validate="empty" id="Title" name="Title" value="@Model.Title" style="width:300px;" /></td>
        </tr>
        <tr>
            <th style="width: 80px;">类型：</th>
            <td>
                <select id="Type" name="Type" class="myselect" validate="empty">
                    <option value=""></option>
                    <option value="0" @(Model.Type == 0 ? "selected='selected'" : "")>顶部统计</option>
                    <option value="1" @(Model.Type == 1 ? "selected='selected'" : "")>左边模块</option>
                    <option value="2" @(Model.Type == 2 ? "selected='selected'" : "")>右边模块</option>
                </select>
            </td>
        </tr>
        <tr>
            <th style="width: 80px;">数据来源：</th>
            <td>
                <select id="DataSourceType" name="DataSourceType" onchange="dstypecng(this.value);" class="myselect" validate="empty">
                    <option value=""></option>
                    <option value="0" @(Model.DataSourceType == 0 ? "selected='selected'" : "")>SQL语句</option>
                    <option value="1" @(Model.DataSourceType == 1 ? "selected='selected'" : "")>C#方法</option>
                    <option value="2" @(Model.DataSourceType == 2 ? "selected='selected'" : "")>URL地址</option>
                </select>
                <span id="DBConnIDSpan" style="display:none;">
                    数据连接：
                    <select class="myselect" id="DbConnId" name="DbConnId">
                        <option value=""></option>
                        @Html.Raw(ViewData["dbconnOptions"])
                    </select>
                </span>
            </td>
        </tr>
        <tr>
            <th style="width: 80px;">来源：</th>
            <td><textarea class="mytextarea" validate="empty" style="width:99%;height:160px;" name="DataSource" id="DataSource">@Model.DataSource</textarea></td>
        </tr>
        <tr>
            <th style="width: 80px;">连接地址：</th>
            <td><input type="text" class="mytext" id="LinkURL" name="LinkURL" style="width:99%;" value="@Model.LinkURL" /></td>
        </tr>
        <tr>
            <th style="width: 80px;">图标：</th>
            <td><input type="text" class="myico" source="/Images/ico" id="Ico" name="Ico" value="@Model.Ico" style="width:300px;" /></td>
        </tr>
        <tr>
            <th style="width: 80px;">背景颜色：</th>
            <td><input type="text" class="mytext" id="BackgroundColor" name="BackgroundColor" style="width:300px;" value="@Model.BackgroundColor" /></td>
        </tr>
        <tr>
            <th style="width: 80px;">字体颜色：</th>
            <td><input type="text" class="mytext" id="FontColor" name="FontColor" style="width:300px;" value="@Model.FontColor" /></td>
        </tr>
        <tr>
            <th style="width: 80px;">使用对象：</th>
            <td><input type="text" class="mymember" id="UseOrganizes" name="UseOrganizes" style="width:300x;" value="@Model.UseOrganizes" /></td>
        </tr>

        <tr>
            <th style="width: 80px;">备注：</th>
            <td><input type="text" class="mytext" id="Note" name="Note" style="width:99%;" value="@Model.Note" /></td>
        </tr>
        <tr>
            <th style="width: 80px;">排序：</th>
            <td><input type="text" class="mytext" id="Sort" name="Sort" style="" value="@Model.Sort" /></td>
        </tr>
    </table>
    <div class="buttondiv">
        <input type="button" class="mybutton" value=" 保 存 " onclick="save(this);" />
        <input type="button" class="mybutton" value=" 返 回 " onclick="window.location='Index?@Html.Raw(ViewData["query"])'" />
    </div>
</form>
<script type="text/javascript">
    $(function(){
        dstypecng($("#DataSourceType").val());
        $("#BackgroundColor").bigColorpicker();
        $("#FontColor").bigColorpicker();
    });
    function dstypecng(type) {
        if ("0" == type) {
            $("#DBConnIDSpan").show();
        }
        else {
            $("#DBConnIDSpan").hide();
        }
    }
    function save(but) {
        var f = document.forms[0];
        if (new RoadUI.Validate().validateForm(f)) {
            var o = RoadUI.Core.serializeForm($(f));
            $(but).prop("disabled", true);
            $.ajax({
                url: "EditSave?@(Html.Raw(ViewData["query"]))", data: o, type: "post", success: function (text) {
                    if (RoadUI.Core.checkLogin(text, false)) {
                        alert(text);
                        window.location ='Index?@Html.Raw(ViewData["query"])'
                    }
                    $(but).prop("disabled", false);
                }
            });
        }
    }
</script>